package dmmm.components;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;

public class KMADR extends LogicalComponent { // @Darko

	private ArrayList<Integer> stepsDec;

	public KMADR() {
		super(8, 1, false);
		out[0].setIsInt();

		stepsDec = new ArrayList<Integer>();
		int counter = 0;
		BufferedReader reader=null;
		try {
			reader = new BufferedReader(new FileReader(
					"conf/dmmm/kmadr.txt"));
			String line;
			while ((line = reader.readLine()) != null) {

				stepsDec.add(counter++, Integer.parseInt(line));
			}
		} catch (Exception e) {
		}finally{
			if(reader!=null)
				try {
					reader.close();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
		}
	}

	public void func() {

		int i = 0;
		for (; i < in.length; i++) {
			if (in[i].getBoolVal()) {
				break;
			}
		}
		if (i < in.length)
			out[0].setIntVal(stepsDec.get(i));
	}
}
